package com.ruoyi.web.controller.his;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HisEngineRulePrescriptionRights;
import com.ruoyi.system.service.IHisEngineRulePrescriptionRightsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 处方权规则Controller
 * 
 * @author Alan
 * @date 2024-03-07
 */
@RestController
@RequestMapping("/system/rights")
public class HisEngineRulePrescriptionRightsController extends BaseController
{
    @Autowired
    private IHisEngineRulePrescriptionRightsService hisEngineRulePrescriptionRightsService;

    /**
     * 查询处方权规则列表
     */
//    @PreAuthorize("@ss.hasPermi('system:rights:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisEngineRulePrescriptionRights hisEngineRulePrescriptionRights)
    {
        startPage();
        List<HisEngineRulePrescriptionRights> list = hisEngineRulePrescriptionRightsService.selectHisEngineRulePrescriptionRightsList(hisEngineRulePrescriptionRights);
        return getDataTable(list);
    }

    /**
     * 导出处方权规则列表
     */
//    @PreAuthorize("@ss.hasPermi('system:rights:export')")
    @Log(title = "处方权规则", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HisEngineRulePrescriptionRights hisEngineRulePrescriptionRights)
    {
        List<HisEngineRulePrescriptionRights> list = hisEngineRulePrescriptionRightsService.selectHisEngineRulePrescriptionRightsList(hisEngineRulePrescriptionRights);
        ExcelUtil<HisEngineRulePrescriptionRights> util = new ExcelUtil<HisEngineRulePrescriptionRights>(HisEngineRulePrescriptionRights.class);
        return util.exportExcel(list, "处方权规则数据");
    }

    /**
     * 获取处方权规则详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:rights:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hisEngineRulePrescriptionRightsService.selectHisEngineRulePrescriptionRightsById(id));
    }

    /**
     * 新增处方权规则
     */
//    @PreAuthorize("@ss.hasPermi('system:rights:add')")
    @Log(title = "处方权规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HisEngineRulePrescriptionRights hisEngineRulePrescriptionRights)
    {
        return toAjax(hisEngineRulePrescriptionRightsService.insertHisEngineRulePrescriptionRights(hisEngineRulePrescriptionRights));
    }

    /**
     * 修改处方权规则
     */
//    @PreAuthorize("@ss.hasPermi('system:rights:edit')")
    @Log(title = "处方权规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HisEngineRulePrescriptionRights hisEngineRulePrescriptionRights)
    {
        return toAjax(hisEngineRulePrescriptionRightsService.updateHisEngineRulePrescriptionRights(hisEngineRulePrescriptionRights));
    }

    /**
     * 删除处方权规则
     */
//    @PreAuthorize("@ss.hasPermi('system:rights:remove')")
    @Log(title = "处方权规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hisEngineRulePrescriptionRightsService.deleteHisEngineRulePrescriptionRightsByIds(ids));
    }
}
